<?
require("config.php");

$show_backnav = "product_menu";
$location_status .= "| Edit";

$menuname = array(
	"Info",
	"Pictures",
	"Color",
	"Size",
	"Specification",
	"Features",
	"Accessories",
	"Packaging",
);

$menutarget = array(
	"edit",
	"edit_pictures",
	"edit_color",
	"edit_size",
	"edit_specification",
	"edit_features",
	"edit_accessories",
	"edit_packaging",
);

$menutype = 2;

if (NULL!=$action){
   $field = array(
	"code",
	"name",
	"description",
	"unit",
	"brand",
	"type",
	"category",
	"fabric",
	"price_euro",
	"price_gbp",
	"price_hkd",
	"price_usd",
	"remark",
	);


   $content = array(
	$Code,
	$Name,
	$Description,
	$Unit,
	$Brand,
	$Type,
	$Category,
	$Fabric,
	$Euro,
	$Gbp,
	$Hkd,
	$Usd,
	$Remarks,
	);

   $exp = "id=$id";

   myUpdate($table,$field,$content,$exp);


   header("location:edit_info.php?id=$id&target=edit_pictures&a=0");

   exit();

}


if (!checkRecord($table,$id)){

	header("location:" . $rela_path . "share/msg.php?v=9002");
  
}

$Query = "select 
	code,
	name,
	description,
	unit,
	brand,
	type,
	category,
	fabric,
	price_euro,
	price_gbp,
	price_hkd,
	price_usd,
	remark 
from pro_basic where id=$id Limit 1";

$r = myQuery($Query);

$Code=$r[0][0];
$Name=$r[0][1];
$Description=$r[0][2];
$Unit=$r[0][3];
$Brand=$r[0][4];
$Type=$r[0][5];
$Category=$r[0][6];
$Fabric=$r[0][7];
$Price_euro=$r[0][8];
$Price_gbp=$r[0][9];
$Price_hkd=$r[0][10];
$Price_usd=$r[0][11];
$Remark =$r[0][12];


$Query = "select code, name from pro_brand";
$brands = myQuery($Query);

$Query = "select code, name from pro_type";
$types = myQuery($Query);


$Query = "select code, name from pro_category";
$categorys = myQuery($Query);


require($rela_path . "inc/header.php");

?>

<!--Content Start-->
<form action="" method="post" name="form1">                    <table width="95%" border="0" align="center">
                      <tr> 
                        
      <td align="right">
	  
	  <input type="image" src="../../images/bt_cancel.gif" width="78" height="23" onclick="Redirect('product_menu.php',1);return false;"> 
        <input type="image" src="../../images/bt_save.gif" width="76" height="22"> 


      </td>
                      </tr>
                    </table>
                    <table width="95%" border="0" align="center">
                      <tr> 
                        <td align="right">&nbsp; </td>
                      </tr>
                      <tr> 
                        <td><table border="0" cellspacing="0" cellpadding="2">
                            <tr> 
                              <td>&nbsp;</td>
                              <td>&nbsp;</td>
                            </tr>
                            <tr> 
                              <td class="tdheader">Code :</td>
                              <td> <input type="text" class="text" name="Code" value="<?print($Code)?>"> 
							  
							  






<!--hidden filed-->
<input name="action" type="hidden" value="add">
<input name="id" type="hidden" value="<?print($id)?>">

							  
							  
							  
							  
							  </td>
                            </tr>
                            <tr> 
                              <td class="tdheader">Name :</td>
                              <td> <textarea class="text" name="Name" cols="40" rows="2"><?print($Name)?></textarea> 
                              </td>
                            </tr>
                            <tr> 
                              <td class="tdheader">Description :</td>
                              <td> <textarea class="text" name="Description" cols="40" rows="5"><?print($Description)?></textarea> 
                              </td>
                            </tr>
                            <tr> 
                              <td class="tdheader">Unit :</td>
                              <td> 
							  
							  
<select class="select" name="Unit">
<?

$units = array(
  "PC",
  "DZ",
  "PAIR",
  "BOX",
  );

for ($i=0;$i<count($units);$i++){

	$active = NULL;
	if ($units[$i] == $Unit) $active = "SELECTED";

	print("<option value='" . $units[$i] . "' $active>" . $units[$i] . "</option>");
}

?>
</select> 	
								
								
								
								</td>
                            </tr>
                            <tr> 
                              <td class="tdheader">Brand :</td>
                              <td> 


<select class="select" name="Brand">
<!--<option selected>SELECT</option>-->
<?
for ($i=0;$i<count($brands);$i++){

	$active = NULL;

	if ($brands[$i][1] == $Brand) $active = "SELECTED";

	print("<option value='" . $brands[$i][1] . "' $active>" . $brands[$i][1] . "</option>");
}

?>
</select> 


</td>
                            </tr>
                            <tr>
                              <td class="tdheader">Type :</td>
                              <td> 
<select class="select" name="Type">
<!--<option selected>SELECT</option>-->
<?
for ($i=0;$i<count($types);$i++){

	$active = NULL;
	if ($types[$i][1] == $Type) $active = "SELECTED";

	print("<option value='" . $types[$i][1] . "' $active>" . $types[$i][1] . "</option>");
}

?>
</select> 
							  

								
								</td>
                            </tr>
                            <tr> 
                              <td class="tdheader">Category :</td>
                              <td> 
							  
<select class="select" name="Category">
<!--<option selected>SELECT</option>-->
<?
for ($i=0;$i<count($categorys);$i++){

	$active = NULL;
	if ($categorys[$i][1] == $Category) $active = "SELECTED";

	print("<option value='" . $categorys[$i][1] . "' $active>" . $categorys[$i][1] . "</option>");
}

?>
</select> 



								
								
								
								</td>
                            </tr>
                            <tr> 
                              <td class="tdheader">Fabric :</td>
                              <td> <textarea class="text" name="Fabric" cols="40" rows="5"><?print($Fabric)?></textarea> 
                              </td>
                            </tr>
                            <tr> 
                              <td class="tdheader">Price : </td>
                              <td> <input type="text" class="text" name="Euro" size="10" value="<?print($Price_euro)?>">
                                EURO<br> <input type="text" class="text" name="Gbp" size="10" value="<?print($Price_gbp)?>">
                                GBP<br> <input type="text" class="text" name="Hkd" size="10" value="<?print($Price_hkd)?>">
                                HKD<br> <input type="text" class="text" name="Usd" size="10" value="<?print($Price_usd)?>">
                                USD <br> </td>
                            </tr>
                            <tr> 
                              <td class="tdheader">Remarks :</td>
                              <td> <textarea class="text" name="Remarks" cols="40" rows="5"><?print($Remark)?></textarea> 
                              </td>
                            </tr>
                            <tr> 
                              <td>&nbsp;</td>
                              <td>&nbsp;</td>
                            </tr>
                          </table></td>
                      </tr>
                    </table>
                    <table width="95%" border="0" align="center">
                      <tr> 
                        
      <td align="right">
	  
	  <input type="image" src="../../images/bt_cancel.gif" width="78" height="23" onclick="Redirect('product_menu.php',1);return false;"> 
        <input type="image" src="../../images/bt_save.gif" width="76" height="22"> 


      </td>
                      </tr>
                    </table>
                  </form>
            <!--Content End-->
            <?
require($rela_path . "inc/footer.php");
?>
        